<?php
class Print_colours extends Controller{
    
    function Print_colours(){
        parent::Controller();
        $this->load->library('session');
	    if($this->session->userdata('admin') == '')
    	{
    		 redirect('admin');
    	}
       
         $this->load->helper(array('form','tiap_helper','html'));
       $this->load->library('form_validation'); 
         $this->load->model('print_colours_model');
    }
    
   
    function move($type = NULL)
    {
        
     
   
        $data['messages'] = $this->print_colours_model->moveup($this->input->post('id'));
        
         
    	$this->load->view(TEMPLATE_NAME.'/admin/print_colours/messages_list',$data);
        redirect('admin/print_colours');
    }
	
	function setdefault()
	{
		$ids = $this->input->post('papercolours');
		if(count($ids) == 1)
		{
			foreach($ids as $vals)
			{
				$val = $vals;
			}
		}
		
		
		$data['messages'] = $this->print_colours_model->setdefault($val);
        
         
    	//$this->load->view(TEMPLATE_NAME.'/admin/print_colours/messages_list',$data);
        redirect('admin/print_colours');
	}
	
    function index(){
        
        	$data = array();
    	
		 $page = (int)$this->uri->segment(4);
		 $edit_id = (int)$this->uri->segment(5);
		 //$data_id['id']=$edit_id;
		$data['edit']=$this->print_colours_model->get_print_colours_detail($edit_id );
		$page = ($page == '')?0:$page;
		
	   	$per_page = 15;
    	$data['total_print_colours'] = $this->print_colours_model->total_print_colours();
		// pagination start
		$this->load->library('pagination');
		$config['base_url'] = site_url('admin/print_colours/index/');
		$config['total_rows'] = $data['total_print_colours'];
		$config['per_page'] = $per_page;
	
		$config['uri_segment'] = 4;

		$this->pagination->initialize($config); 

		$data['pagination'] =  $this->pagination->create_links();
		//pagination end
    	$data['order_by'] = $order_by;
    	
        
      $data['paper_colours']=$this->print_colours_model->list_print_colours($per_page,$page);  
       $data['page']=$page;
		$this->load->view(TEMPLATE_NAME.'/admin/print_colours/list',$data);
        
    }
    function detail(){
        
        	$data = array();
    	    $id = (int)$this->uri->segment(4);
            $page = (int)$this->uri->segment(5);
            $data['page']=$page;	
			$data['paper_colours_detail']=$this->print_colours_model->get_print_colours_detail($id );
			$this->load->view(TEMPLATE_NAME.'/admin/print_colours/detail',$data);
        
    }
    function delete(){

     
         $papercolours_id= $this->input->post('papercolours');
       
         $check= $this->print_colours_model->delete_print_colours($papercolours_id);
        
           redirect('admin/print_colours');
        
		}
        
   function form(){
		  $id= $this->input->post('id');
		      $data = array();
    	    $id = (int)$this->uri->segment(4);
             $page= (int)$this->uri->segment(5);
            $data['page']=$page;
            $data['paper_colours_detail']=$this->print_colours_model->get_print_colours_detail($id );
			$this->load->view(TEMPLATE_NAME.'/admin/print_colours/action',$data);
        
		}
  function action(){
    
  
        $page= $this->input->post('page');
        $data['page']=$page;
      
           $this->print_colours_model->do_action();
            
            redirect('admin/print_colours/index/'.$page);
         
        
		}
    
}
?>
